<?php

namespace app\store\controller\member;

use app\store\controller\BaseController;
use app\store\service\UserService;
use think\facade\View;
use app\store\model\StoreUser;
use app\store\service\StoreUserGradeService;

class UserController extends BaseController
{
    public function index()
    {   

        $param = $this->request->param();

        $storeUserService = new UserService();
        $list = $storeUserService->getUserList($param);

        return View::fetch('',['list' => $list]);
    }

    public function option()
    {
        $param = $this->request->param();

        $storeUserService = new UserService();
        $list = $storeUserService->getUserList($param);

        View::engine()->layout(false);

        return View::fetch('',['list' => $list]);
    }

    public function edit()
    {
        $id = $this->request->param('id/d');

        $gradeOptions = StoreUserGradeService::getStoreUserGradeOptions();

        $StoreUserService = new UserService();
        $row = $StoreUserService->findUser($id);


        return View::fetch('',['gradeOptions' => $gradeOptions,'row' => $row]);
    }

    public function update()
    {
        $param = $this->request->param();;


        StoreUser::update($param);

        return json(['code' => 1, 'msg' => '更新成功!']);
    }


    
}